import { get, post } from "@/api/axios"
import type { BiuJsonResult } from "@/api/biu-json-result"



export interface CaptchaImage {
  id: string
  imageBase64: string
}

export interface LoginRequest {
  password: string
  captchaId?: string
  captchaCode?: string
}

export interface ChangePasswordRequest {
  oldPassword: string
  newPassword: string
}

export function doGenerateCaptcha() {
  return get<BiuJsonResult<CaptchaImage>>("/api/passport/generate-captcha")
}

export function doLogin(request: LoginRequest) {
  return post<BiuJsonResult<string>>("/api/passport/login", request)
}

export function doLogout() {
  return post("/api/passport/logout")
}

export function doChangePassword(request: ChangePasswordRequest) {
  return post<BiuJsonResult<boolean>>("/api/passport/change-password", request)
}
